//
//  GuideSubViewController.swift
//  ManBetX
//
//  Created by Cocoa on 2020/4/23.
//  Copyright © 2020 Fullen. All rights reserved.
//

import UIKit

enum GuideSubType {
    case first
    case second
    case third
}

class GuideSubViewController: UIViewController {

    @IBOutlet weak var bgImageView: UIImageView!
    @IBOutlet weak var jumpButton: UIButton!
    
    var subType = GuideSubType.first
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        configureUI()
    }
    
    func configureUI(){
        
        var preImageString = "guide_first_"
        if self.subType == GuideSubType.first {
            preImageString = "guide_first_"
            self.jumpButton.isHidden = true
            
        }else if self.subType == GuideSubType.second {
            preImageString = "guide_second_"
            self.jumpButton.isHidden = true
            
        }else if self.subType == GuideSubType.third {
            preImageString = "guide_third_"
            self.jumpButton.isHidden = false
        }
        
        if isIphone6 {
            let allImageString = String(format: "%@750x1334", preImageString)
            self.bgImageView.image = UIImage.init(named: allImageString)
        }else if isIphone6P {
            let allImageString = String(format: "%@1242x2208", preImageString)
            self.bgImageView.image = UIImage.init(named: allImageString)
        }else if isIphoneX {
            let allImageString = String(format: "%@1125x2436", preImageString)
            self.bgImageView.image = UIImage.init(named: allImageString)
        }else if isIphoneXR {
            let allImageString = String(format: "%@828x1792", preImageString)
            self.bgImageView.image = UIImage.init(named: allImageString)
        }else if isIphoneXS_Max {
            let allImageString = String(format: "%@1242x2688", preImageString)
            self.bgImageView.image = UIImage.init(named: allImageString)
        }
    }
    
    
    @IBAction func jumpButtonClick(_ sender: UIButton) {
        
        self.enterTabBarViewController()
        
        UserDefaults.standard.set(true, forKey: DefaultKey.APP_NOTFIRST_LAUNCH)
    }
    
    // 跳转TabBarViewController
    func enterTabBarViewController() {
        
        let tabBarViewController = TabBarViewController.instanceFromStoryboard()!
        
        if #available(iOS 13.0, *) {
    
            UIApplication.shared.windows.first?.rootViewController = tabBarViewController
        }else {
            UIApplication.shared.keyWindow?.rootViewController = tabBarViewController
        }
    }
}
